Add two virtualized functions gdk_drawable_get_clip_region - to get the
authorOwen Taylor <otaylor@redhat.com>
Fri, 15 Dec 2000 01:46:41 +0000 (01:46 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 15 Dec 2000 01:46:41 +0000 (01:46 +0000)
Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>

        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
Add two virtualized functions gdk_drawable_get_clip_region - to
get the clip region when drawing.

* gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
use invalidate_region.

* gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
region.

* acconfig.h configure.in: Check for Xft. For now, assume
that if Xft is found, Pango was compiled with Xft support
as well.

* gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add
gdk_colormap_query_color().

* gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
with Xft if appropriate.

* gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
a pangoxft context if we have XFT and the environment
variable GD_USE_XFT is set.

* gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
and also possibly an XftDraw structure.

        * gtk/gtkfontsel.c: Handle the case where the font from the
style doesn't match any of the fonts a bit better.

* gtk/testgtk.c: Add tabs between directional segments for
hebrew/arabic test. (Not really necessary, just a little
prettier.)

26 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
acconfig.h
configure.in
gdk/gdkcolor.h
gdk/gdkdraw.c
gdk/gdkdrawable.h
gdk/gdkpixmap.c
gdk/gdkwindow.c
gdk/x11/gdkcolor-x11.c
gdk/x11/gdkdrawable-x11.c
gdk/x11/gdkgc-x11.c
gdk/x11/gdkgeometry-x11.c
gdk/x11/gdkmain-x11.c
gdk/x11/gdkpango-x11.c
gdk/x11/gdkprivate-x11.h
gdk/x11/gdkwindow-x11.c
gdk/x11/gdkx.h
gtk/gtkfontsel.c
gtk/testgtk.c
tests/testgtk.c

index 73ab05d4271a4837be2642f2a863848f79be5325..0f848f51419a75c0480202c3710bc5c0ed28bbec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>
+
+        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
+       Add two virtualized functions gdk_drawable_get_clip_region - to
+       get the clip region when drawing.
+       
+       * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
+       use invalidate_region.
+
+       * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
+       region.
+
+       * acconfig.h configure.in: Check for Xft. For now, assume
+       that if Xft is found, Pango was compiled with Xft support
+       as well.
+
+       * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add 
+       gdk_colormap_query_color().
+       
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
+       with Xft if appropriate.
+
+       * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
+       a pangoxft context if we have XFT and the environment
+       variable GD_USE_XFT is set.
+       
+       * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
+       and also possibly an XftDraw structure.
+
+        * gtk/gtkfontsel.c: Handle the case where the font from the
+       style doesn't match any of the fonts a bit better.
+       
+       * gtk/testgtk.c: Add tabs between directional segments for
+       hebrew/arabic test. (Not really necessary, just a little
+       prettier.)
+
 2000-12-14  Havoc Pennington  <hp@redhat.com>
 
        * gtk/testtext.c (fill_file_buffer): fix unicode validation when
index 73ab05d4271a4837be2642f2a863848f79be5325..0f848f51419a75c0480202c3710bc5c0ed28bbec 100644 (file)
@@ -1,3 +1,39 @@
+Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>
+
+        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
+       Add two virtualized functions gdk_drawable_get_clip_region - to
+       get the clip region when drawing.
+       
+       * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
+       use invalidate_region.
+
+       * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
+       region.
+
+       * acconfig.h configure.in: Check for Xft. For now, assume
+       that if Xft is found, Pango was compiled with Xft support
+       as well.
+
+       * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add 
+       gdk_colormap_query_color().
+       
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
+       with Xft if appropriate.
+
+       * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
+       a pangoxft context if we have XFT and the environment
+       variable GD_USE_XFT is set.
+       
+       * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
+       and also possibly an XftDraw structure.
+
+        * gtk/gtkfontsel.c: Handle the case where the font from the
+       style doesn't match any of the fonts a bit better.
+       
+       * gtk/testgtk.c: Add tabs between directional segments for
+       hebrew/arabic test. (Not really necessary, just a little
+       prettier.)
+
 2000-12-14  Havoc Pennington  <hp@redhat.com>
 
        * gtk/testtext.c (fill_file_buffer): fix unicode validation when
index 73ab05d4271a4837be2642f2a863848f79be5325..0f848f51419a75c0480202c3710bc5c0ed28bbec 100644 (file)
@@ -1,3 +1,39 @@
+Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>
+
+        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
+       Add two virtualized functions gdk_drawable_get_clip_region - to
+       get the clip region when drawing.
+       
+       * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
+       use invalidate_region.
+
+       * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
+       region.
+
+       * acconfig.h configure.in: Check for Xft. For now, assume
+       that if Xft is found, Pango was compiled with Xft support
+       as well.
+
+       * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add 
+       gdk_colormap_query_color().
+       
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
+       with Xft if appropriate.
+
+       * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
+       a pangoxft context if we have XFT and the environment
+       variable GD_USE_XFT is set.
+       
+       * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
+       and also possibly an XftDraw structure.
+
+        * gtk/gtkfontsel.c: Handle the case where the font from the
+       style doesn't match any of the fonts a bit better.
+       
+       * gtk/testgtk.c: Add tabs between directional segments for
+       hebrew/arabic test. (Not really necessary, just a little
+       prettier.)
+
 2000-12-14  Havoc Pennington  <hp@redhat.com>
 
        * gtk/testtext.c (fill_file_buffer): fix unicode validation when
index 73ab05d4271a4837be2642f2a863848f79be5325..0f848f51419a75c0480202c3710bc5c0ed28bbec 100644 (file)
@@ -1,3 +1,39 @@
+Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>
+
+        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
+       Add two virtualized functions gdk_drawable_get_clip_region - to
+       get the clip region when drawing.
+       
+       * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
+       use invalidate_region.
+
+       * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
+       region.
+
+       * acconfig.h configure.in: Check for Xft. For now, assume
+       that if Xft is found, Pango was compiled with Xft support
+       as well.
+
+       * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add 
+       gdk_colormap_query_color().
+       
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
+       with Xft if appropriate.
+
+       * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
+       a pangoxft context if we have XFT and the environment
+       variable GD_USE_XFT is set.
+       
+       * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
+       and also possibly an XftDraw structure.
+
+        * gtk/gtkfontsel.c: Handle the case where the font from the
+       style doesn't match any of the fonts a bit better.
+       
+       * gtk/testgtk.c: Add tabs between directional segments for
+       hebrew/arabic test. (Not really necessary, just a little
+       prettier.)
+
 2000-12-14  Havoc Pennington  <hp@redhat.com>
 
        * gtk/testtext.c (fill_file_buffer): fix unicode validation when
index 73ab05d4271a4837be2642f2a863848f79be5325..0f848f51419a75c0480202c3710bc5c0ed28bbec 100644 (file)
@@ -1,3 +1,39 @@
+Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>
+
+        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
+       Add two virtualized functions gdk_drawable_get_clip_region - to
+       get the clip region when drawing.
+       
+       * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
+       use invalidate_region.
+
+       * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
+       region.
+
+       * acconfig.h configure.in: Check for Xft. For now, assume
+       that if Xft is found, Pango was compiled with Xft support
+       as well.
+
+       * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add 
+       gdk_colormap_query_color().
+       
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
+       with Xft if appropriate.
+
+       * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
+       a pangoxft context if we have XFT and the environment
+       variable GD_USE_XFT is set.
+       
+       * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
+       and also possibly an XftDraw structure.
+
+        * gtk/gtkfontsel.c: Handle the case where the font from the
+       style doesn't match any of the fonts a bit better.
+       
+       * gtk/testgtk.c: Add tabs between directional segments for
+       hebrew/arabic test. (Not really necessary, just a little
+       prettier.)
+
 2000-12-14  Havoc Pennington  <hp@redhat.com>
 
        * gtk/testtext.c (fill_file_buffer): fix unicode validation when
index 73ab05d4271a4837be2642f2a863848f79be5325..0f848f51419a75c0480202c3710bc5c0ed28bbec 100644 (file)
@@ -1,3 +1,39 @@
+Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>
+
+        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
+       Add two virtualized functions gdk_drawable_get_clip_region - to
+       get the clip region when drawing.
+       
+       * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
+       use invalidate_region.
+
+       * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
+       region.
+
+       * acconfig.h configure.in: Check for Xft. For now, assume
+       that if Xft is found, Pango was compiled with Xft support
+       as well.
+
+       * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add 
+       gdk_colormap_query_color().
+       
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
+       with Xft if appropriate.
+
+       * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
+       a pangoxft context if we have XFT and the environment
+       variable GD_USE_XFT is set.
+       
+       * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
+       and also possibly an XftDraw structure.
+
+        * gtk/gtkfontsel.c: Handle the case where the font from the
+       style doesn't match any of the fonts a bit better.
+       
+       * gtk/testgtk.c: Add tabs between directional segments for
+       hebrew/arabic test. (Not really necessary, just a little
+       prettier.)
+
 2000-12-14  Havoc Pennington  <hp@redhat.com>
 
        * gtk/testtext.c (fill_file_buffer): fix unicode validation when
index 73ab05d4271a4837be2642f2a863848f79be5325..0f848f51419a75c0480202c3710bc5c0ed28bbec 100644 (file)
@@ -1,3 +1,39 @@
+Thu Dec 14 20:22:31 2000  Owen Taylor  <otaylor@redhat.com>
+
+        * gdk/{gdkdrawable.[ch],gdkpixmap.c,gdkwindow.c,x11/gdkwindow.c}:
+       Add two virtualized functions gdk_drawable_get_clip_region - to
+       get the clip region when drawing.
+       
+       * gdk/gdkwindow.c (gdk_window_invalidate_rect): Rewrite to simple
+       use invalidate_region.
+
+       * gdk/gdkwindow.c (gdk_window_invalidate_region): Clip to visible
+       region.
+
+       * acconfig.h configure.in: Check for Xft. For now, assume
+       that if Xft is found, Pango was compiled with Xft support
+       as well.
+
+       * gdk/gdkcolor.h gdk/x11/gdkcolor-x11.c: Add 
+       gdk_colormap_query_color().
+       
+       * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_glyphs): Draw
+       with Xft if appropriate.
+
+       * gdk/x11/gdkpango-x11.c (gdk_pango_context_get): Create
+       a pangoxft context if we have XFT and the environment
+       variable GD_USE_XFT is set.
+       
+       * gdk/x11/gdkx.h (struct _GdkGCX11): Cache the fg_pixel
+       and also possibly an XftDraw structure.
+
+        * gtk/gtkfontsel.c: Handle the case where the font from the
+       style doesn't match any of the fonts a bit better.
+       
+       * gtk/testgtk.c: Add tabs between directional segments for
+       hebrew/arabic test. (Not really necessary, just a little
+       prettier.)
+
 2000-12-14  Havoc Pennington  <hp@redhat.com>
 
        * gtk/testtext.c (fill_file_buffer): fix unicode validation when
index f9404016ee4638e25820b3bb7cffa32762dc2c64..32fc21dbf22706e3ec5f83ebfb4e67c2818b3d4b 100644 (file)
@@ -32,6 +32,7 @@
 #undef HAVE_SYS_SELECT_H
 #undef HAVE_SYS_TIME_H
 #undef HAVE_XCONVERTCASE
+#undef HAVE_XFT
 
 #undef NO_FD_SET
 
index 2846aab07bc3026426461b9194f375e52d4ce4e8..7e4bb057ab1a879fa3fcc2a39962d2f860d64737 100644 (file)
@@ -398,6 +398,22 @@ if test "x$gdktarget" = "xx11"; then
       ,
       $x_libs)
 
+  #
+  # Checks for Xft/XRender
+  # 
+  have_xft=false
+  XFT_LIBS=""
+  AC_CHECK_LIB(Xrender, XRenderFindFormat, 
+    AC_CHECK_LIB(Xft, XftFontOpen, have_xft=true, :, -lXrender $X_LIBS)
+  ,:,-lXext $X_LIBS)
+
+  if $have_xft = 'true' ; then
+    X_LIBS="-lXft -lXrender -lXext $X_LIBS"
+  fi
+
+  AC_DEFINE(HAVE_XFT)
+  AM_CONDITIONAL(HAVE_XFT, $have_xft) 
+
   # Check for XIM support.
 
   AC_CHECK_LIB(X11, XUnregisterIMInstantiateCallback,
@@ -562,6 +578,9 @@ fi
 if test "x$gdktarget" = "xx11"; then
        PANGO_CFLAGS="`$PANGO_CONFIG --cflags pangox`"
        PANGO_LIBS="`$PANGO_CONFIG --libs pangox`"
+       if $have_xft = true ; then
+            PANGO_LIBS="$PANGO_LIBS -lpangoxft"
+        fi
 else
        PANGO_CFLAGS="`$PANGO_CONFIG --cflags pango`"
        PANGO_LIBS="`$PANGO_CONFIG --libs pango`"
index 811d1cf93d4b069397e9474a7e68d6c5b7110534..07417f8029d5ddf929743640a5ac79fa956232c8 100644 (file)
@@ -82,6 +82,9 @@ gboolean gdk_colormap_alloc_color (GdkColormap *colormap,
 void     gdk_colormap_free_colors (GdkColormap *colormap,
                                   GdkColor    *colors,
                                   gint         ncolors);
+void     gdk_colormap_query_color (GdkColormap *colormap,
+                                  gulong       pixel,
+                                  GdkColor    *result);
 
 GdkVisual *gdk_colormap_get_visual (GdkColormap *colormap);
      
index fcab539e584cf3173ed464950e20461c996be9b0..a6fd64d28965257d53ed77c31cce111ee61277b3 100644 (file)
 #include "gdkwindow.h"
 
 static GdkDrawable* gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
-                                                              gint         x,
-                                                              gint         y,
-                                                              gint         width,
-                                                              gint         height,
-                                                              gint        *composite_x_offset,
-                                                              gint        *composite_y_offset);
+                                                             gint         x,
+                                                             gint         y,
+                                                             gint         width,
+                                                             gint         height,
+                                                             gint        *composite_x_offset,
+                                                             gint        *composite_y_offset);
+static GdkRegion *  gdk_drawable_real_get_visible_region     (GdkDrawable *drawable);
 
 static void gdk_drawable_class_init (GdkDrawableClass *klass);
 
@@ -70,6 +71,9 @@ static void
 gdk_drawable_class_init (GdkDrawableClass *klass)
 {
   klass->get_composite_drawable = gdk_drawable_real_get_composite_drawable;
+  /* Default implementation for clip and visible region is the same */
+  klass->get_clip_region = gdk_drawable_real_get_visible_region;
+  klass->get_visible_region = gdk_drawable_real_get_visible_region;
 }
 
 /* Manipulation of drawables
@@ -525,3 +529,58 @@ gdk_drawable_real_get_composite_drawable (GdkDrawable *drawable,
   
   return GDK_DRAWABLE (g_object_ref (G_OBJECT (drawable)));
 }
+
+/**
+ * gdk_drawable_get_clip_region:
+ * @drawable: a #GdkDrawable
+ * 
+ * Computes the region of a drawable that potentially can be written
+ * to by drawing primitives. This region will not take into account
+ * the clip region for the GC, and may also not take into account
+ * other factors such as if the window is obscured by other windows,
+ * but no area outside of this region will be affected by drawing
+ * primitives.
+ * 
+ * Return value: a #GdkRegion. This must be freed with gdk_region_destroy()
+ *               when you are done.
+ **/
+GdkRegion *
+gdk_drawable_get_clip_region (GdkDrawable *drawable)
+{
+  g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+
+  return GDK_DRAWABLE_GET_CLASS (drawable)->get_clip_region (drawable);
+}
+
+/**
+ * gdk_drawable_get_visible_region:
+ * @drawable: 
+ * 
+ * Computes the region of a drawable that is potentially visible.
+ * This does not necessarily take into account if the window is
+ * obscured by other windows, but no area outside of this region
+ * is visible.
+ * 
+ * Return value: a #GdkRegion. This must be freed with gdk_region_destroy()
+ *               when you are done.
+ **/
+GdkRegion *
+gdk_drawable_get_visible_region (GdkDrawable *drawable)
+{
+  g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
+
+  return GDK_DRAWABLE_GET_CLASS (drawable)->get_visible_region (drawable);
+}
+
+static GdkRegion *
+gdk_drawable_real_get_visible_region (GdkDrawable *drawable)
+{
+  GdkRectangle rect;
+
+  rect.x = 0;
+  rect.y = 0;
+
+  gdk_drawable_get_size (drawable, &rect.width, &rect.height);
+
+  return gdk_region_rectangle (&rect);
+}
index e177ca81a1d0736796afc32cd07cbcda2a56d04c..a35830d23369dbc91d5a0ea11ecbe0115af63700 100644 (file)
@@ -120,6 +120,9 @@ struct _GdkDrawableClass
                               gint          width,
                               gint          height);
 
+  GdkRegion*   (*get_clip_region)    (GdkDrawable  *drawable);
+  GdkRegion*   (*get_visible_region) (GdkDrawable  *drawable);
+
   GdkDrawable* (*get_composite_drawable) (GdkDrawable *drawable,
                                           gint         x,
                                           gint         y,
@@ -260,6 +263,9 @@ GdkImage* gdk_drawable_get_image (GdkDrawable *drawable,
                                   gint         width,
                                   gint         height);
 
+GdkRegion *gdk_drawable_get_clip_region    (GdkDrawable *drawable);
+GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 27fc5f631a1d7ce7e7a5d8f846be345b055c668c..320320c92a7a49e2529ab209d25694e9abea9fe1 100644 (file)
@@ -107,12 +107,11 @@ static void   gdk_pixmap_real_get_size  (GdkDrawable     *drawable,
                                          gint            *width,
                                          gint            *height);
 
-static GdkImage* gdk_pixmap_get_image   (GdkDrawable     *drawable,
-                                         gint             x,
-                                         gint             y,
-                                         gint             width,
-                                         gint             height);
-
+static GdkImage* gdk_pixmap_get_image (GdkDrawable *drawable,
+                                      gint         x,
+                                      gint         y,
+                                      gint         width,
+                                      gint         height);
 
 static GdkVisual*   gdk_pixmap_real_get_visual   (GdkDrawable *drawable);
 static gint         gdk_pixmap_real_get_depth    (GdkDrawable *drawable);
index be6e8d0135d20f68b84fc0e6f2ef5d38821ba0c2..42ded204beda1f616deb7f5754307181cc3fe2fc 100644 (file)
@@ -136,12 +136,14 @@ static void         gdk_window_real_set_colormap (GdkDrawable *drawable,
 static GdkColormap* gdk_window_real_get_colormap (GdkDrawable *drawable);
 
 static GdkDrawable* gdk_window_get_composite_drawable (GdkDrawable *drawable,
-                                                       gint         x,
-                                                       gint         y,
-                                                       gint         width,
-                                                       gint         height,
-                                                       gint        *composite_x_offset,
-                                                       gint        *composite_y_offset);
+                                                      gint         x,
+                                                      gint         y,
+                                                      gint         width,
+                                                      gint         height,
+                                                      gint        *composite_x_offset,
+                                                      gint        *composite_y_offset);
+static GdkRegion*   gdk_window_get_clip_region        (GdkDrawable *drawable);
+static GdkRegion*   gdk_window_get_visible_region     (GdkDrawable *drawable);
 
 static void gdk_window_free_paint_stack (GdkWindow *window);
 
@@ -217,6 +219,8 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
   drawable_class->get_colormap = gdk_window_real_get_colormap;
   drawable_class->get_visual = gdk_window_real_get_visual;
   drawable_class->get_image = gdk_window_get_image;
+  drawable_class->get_clip_region = gdk_window_get_clip_region;
+  drawable_class->get_visible_region = gdk_window_get_visible_region;
   drawable_class->get_composite_drawable = gdk_window_get_composite_drawable;
 }
 
@@ -1207,6 +1211,41 @@ gdk_window_get_composite_drawable (GdkDrawable *window,
   return tmp_pixmap;
 }
 
+static GdkRegion*
+gdk_window_get_clip_region (GdkDrawable *drawable)
+{
+  GdkWindowObject *private = (GdkWindowObject *)drawable;
+  GdkRegion *result;
+
+  result = gdk_drawable_get_clip_region (private->impl);
+
+  if (private->paint_stack)
+    {
+      GdkRegion *paint_region = gdk_region_new ();
+      GSList *tmp_list = private->paint_stack;
+
+      while (tmp_list)
+       {
+         GdkWindowPaint *paint = tmp_list->data;
+         
+         gdk_region_union (paint_region, paint->region);
+       }
+
+      gdk_region_intersect (result, paint_region);
+      gdk_region_destroy (paint_region);
+    }
+
+  return result;
+}
+
+static GdkRegion*
+gdk_window_get_visible_region (GdkDrawable *drawable)
+{
+  GdkWindowObject *private = (GdkWindowObject*) drawable;
+  
+  return gdk_drawable_get_visible_region (private->impl);
+}
+
 static void
 gdk_window_draw_drawable (GdkDrawable *drawable,
                          GdkGC       *gc,
@@ -1710,6 +1749,7 @@ gdk_window_invalidate_rect   (GdkWindow    *window,
                              gboolean      invalidate_children)
 {
   GdkRectangle window_rect;
+  GdkRegion *region;
   GdkWindowObject *private = (GdkWindowObject *)window;
 
   g_return_if_fail (window != NULL);
@@ -1730,55 +1770,10 @@ gdk_window_invalidate_rect   (GdkWindow    *window,
                              &window_rect.height);
       rect = &window_rect;
     }
-  
-  if (private->update_area)
-    {
-      gdk_region_union_with_rect (private->update_area, rect);
-    }
-  else
-    {
-      update_windows = g_slist_prepend (update_windows, window);
-      private->update_area = gdk_region_rectangle (rect);
-
-      if (!private->update_freeze_count && !update_idle)
-       update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW,
-                                      gdk_window_update_idle, NULL, NULL);
-    }
-
-
-  if (invalidate_children)
-    {
-      GList *tmp_list;
-      GdkRectangle child_rect, new_rect;
-
-      tmp_list = private->children;
-      while (tmp_list)
-       {
-         GdkWindowObject *child = tmp_list->data;
-         tmp_list = tmp_list->next;
-
-         if (!child->input_only)
-           {
-              gint width, height;
 
-              gdk_drawable_get_size (GDK_DRAWABLE (child),
-                                     &width, &height);
-              
-             child_rect.x = child->x;
-             child_rect.y = child->y;
-             child_rect.width = width;
-             child_rect.height = height;
-             
-             if (gdk_rectangle_intersect (rect, &child_rect, &new_rect))
-               {
-                 new_rect.x -= child_rect.x;
-                 new_rect.y -= child_rect.y;
-                 
-                 gdk_window_invalidate_rect ((GdkWindow *)child, &new_rect, TRUE);
-               }
-           }
-       }
-    }
+  region = gdk_region_rectangle (rect);
+  gdk_window_invalidate_region (window, region, invalidate_children);
+  gdk_region_destroy (region);
 }
 
 void
@@ -1787,6 +1782,7 @@ gdk_window_invalidate_region (GdkWindow *window,
                              gboolean   invalidate_children)
 {
   GdkWindowObject *private = (GdkWindowObject *)window;
+  GdkRegion *visible_region;
 
   g_return_if_fail (window != NULL);
   g_return_if_fail (GDK_IS_WINDOW (window));
@@ -1796,55 +1792,51 @@ gdk_window_invalidate_region (GdkWindow *window,
   
   if (private->input_only || !private->mapped)
     return;
-  
-  if (private->update_area)
-    {
-      gdk_region_union (private->update_area, region);
-    }
-  else
-    {
-      update_windows = g_slist_prepend (update_windows, window);
-      private->update_area = gdk_region_copy (region);
 
-      if (!private->update_freeze_count && !update_idle)
-       update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW,
-                                      gdk_window_update_idle, NULL, NULL);
-    }
+  visible_region = gdk_drawable_get_visible_region (window);
+  gdk_region_intersect (visible_region, region);
 
-  if (invalidate_children)
+  if (!gdk_region_empty (region))
     {
-      GList *tmp_list;
-      GdkRectangle child_rect;
-      GdkRegion *child_region;
-
-      tmp_list = private->children;
-      while (tmp_list)
+      if (private->update_area)
        {
-         GdkWindowObject *child = tmp_list->data;
-         tmp_list = tmp_list->next;
-
-         if (!child->input_only)
+         gdk_region_union (private->update_area, region);
+       }
+      else
+       {
+         update_windows = g_slist_prepend (update_windows, window);
+         private->update_area = gdk_region_copy (region);
+         
+         if (!private->update_freeze_count && !update_idle)
+           update_idle = g_idle_add_full (GDK_PRIORITY_REDRAW,
+                                          gdk_window_update_idle, NULL, NULL);
+       }
+      
+      if (invalidate_children)
+       {
+         GList *tmp_list;
+         
+         tmp_list = private->children;
+         while (tmp_list)
            {
-              gint width, height;
-
-              gdk_drawable_get_size (GDK_DRAWABLE (child),
-                                     &width, &height);
-              
-             child_rect.x = child->x;
-             child_rect.y = child->y;
-             child_rect.width = width;
-             child_rect.height = height;
-             
-             child_region = gdk_region_rectangle (&child_rect);
-             gdk_region_intersect (child_region, region);
+             GdkWindowObject *child = tmp_list->data;
+             tmp_list = tmp_list->next;
              
-             if (!gdk_region_empty (child_region))
+             if (!child->input_only)
                {
-                 gdk_region_offset (child_region, - child_rect.x, - child_rect.y);
+                 GdkRegion *child_region;
+                 gint x, y;
+
+                 gdk_window_get_position ((GdkWindow *)child, &x, &y);
+
+                 /* This copy could be saved with a little more complexity */
+                 child_region = gdk_region_copy (region);
+                 gdk_region_offset (child_region, -x, -y);
+                 
                  gdk_window_invalidate_region ((GdkWindow *)child, child_region, TRUE);
+                 
+                 gdk_region_destroy (child_region);
                }
-             
-             gdk_region_destroy (child_region);
            }
        }
     }
index 9dff2d55f92bd6144bee7fa07cea09b4365a2074..a20a302d7262cee2fb10c637c0c03fd33f12b500 100644 (file)
@@ -963,6 +963,47 @@ gdk_colormap_alloc_colors (GdkColormap *colormap,
   return nremaining;
 }
 
+void
+gdk_colormap_query_color (GdkColormap *colormap,
+                         gulong       pixel,
+                         GdkColor    *result)
+{
+  XColor xcolor;
+  GdkVisual *visual;
+
+  g_return_if_fail (GDK_IS_COLORMAP (colormap));
+  
+  visual = gdk_colormap_get_visual (colormap);
+
+  switch (visual->type) {
+  case GDK_VISUAL_DIRECT_COLOR:
+  case GDK_VISUAL_TRUE_COLOR:
+    result->red = 65535. * (double)((pixel & visual->red_mask) >> visual->red_shift) / ((1 << visual->red_prec) - 1);
+    result->green = 65535. * (double)((pixel & visual->green_mask) >> visual->green_shift) / ((1 << visual->green_prec) - 1);
+    result->blue = 65535. * (double)((pixel & visual->blue_mask) >> visual->blue_shift) / ((1 << visual->blue_prec) - 1);
+    break;
+  case GDK_VISUAL_STATIC_GRAY:
+  case GDK_VISUAL_GRAYSCALE:
+    result->red = result->green = result->blue = 65535. * (double)pixel/((1<<visual->depth) - 1);
+    break;
+  case GDK_VISUAL_STATIC_COLOR:
+    xcolor.pixel = pixel;
+    XQueryColor (GDK_DISPLAY (), GDK_COLORMAP_XCOLORMAP (colormap), &xcolor);
+    result->red = xcolor.red;
+    result->green = xcolor.green;
+    result->blue =  xcolor.blue;
+    break;
+  case GDK_VISUAL_PSEUDO_COLOR:
+    result->red = colormap->colors[pixel].red;
+    result->green = colormap->colors[pixel].green;
+    result->blue = colormap->colors[pixel].blue;
+    break;
+  default:
+    g_assert_not_reached ();
+    break;
+  }
+}
+
 gboolean
 gdk_color_change (GdkColormap *colormap,
                  GdkColor    *color)
index 9eaf0ad96b00f38da99640c6999f307fdc63b4a6..ed3f2003e049e5a264594ae8d0827446a79e10b0 100644 (file)
  */
 
 #include "gdkprivate-x11.h"
+#include "gdkregion-generic.h"
+
 #include <pango/pangox.h>
 #include <config.h>
 
+#if HAVE_XFT
+#include <pango/pangoxft.h>
+#endif
+
 #include <stdlib.h>
 
 #if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
@@ -564,6 +570,40 @@ gdk_x11_draw_lines (GdkDrawable *drawable,
   g_free (tmp_points);
 }
 
+#if HAVE_XFT
+static void
+update_xft_draw_clip (GdkGC *gc)
+{
+  GdkGCX11 *private = GDK_GC_X11 (gc);
+  int i;
+  
+  if (private->xft_draw)
+    {
+      if (private->clip_region)
+       {
+         GdkRegionBox *boxes = private->clip_region->rects;
+         Region region = XCreateRegion ();
+         
+         for (i=0; i<private->clip_region->numRects; i++)
+           {
+             XRectangle rect;
+             
+             rect.x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT);
+             rect.y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT);
+             rect.width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rect.x;
+             rect.height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rect.y;
+             XUnionRectWithRegion (&rect, region, region);
+           }
+         
+         XftDrawSetClip (private->xft_draw, region);
+         XDestroyRegion (region);
+       }
+      else
+       XftDrawSetClip (private->xft_draw, NULL);
+    }
+}
+#endif  
+
 static void
 gdk_x11_draw_glyphs (GdkDrawable      *drawable,
                     GdkGC            *gc,
@@ -576,10 +616,49 @@ gdk_x11_draw_glyphs (GdkDrawable      *drawable,
 
   impl = GDK_DRAWABLE_IMPL_X11 (drawable);
 
-  pango_x_render (impl->xdisplay,
-                  impl->xid,
-                 GDK_GC_GET_XGC (gc),
-                 font, glyphs, x, y);
+#if HAVE_XFT
+  if (PANGO_XFT_IS_FONT (font))
+    {
+      GdkGCX11 *gc_x11 = GDK_GC_X11 (gc);
+      XftColor xft_color;
+      GdkColormap *cmap;
+      GdkColor color;
+      
+      cmap = gdk_gc_get_colormap (gc);
+
+      _gdk_x11_gc_flush (gc);
+      
+      if (!gc_x11->xft_draw)
+       {
+         gc_x11->xft_draw = XftDrawCreate (impl->xdisplay,
+                                           impl->xid,
+                                           GDK_VISUAL_XVISUAL (gdk_colormap_get_visual (cmap)),
+                                           GDK_COLORMAP_XCOLORMAP (cmap));
+         update_xft_draw_clip (gc);
+       }
+      
+      else
+       {
+         XftDrawChange (gc_x11->xft_draw, impl->xid);
+         update_xft_draw_clip (gc);
+       }
+      
+      gdk_colormap_query_color (cmap, gc_x11->fg_pixel, &color);
+      
+      xft_color.color.red = color.red;
+      xft_color.color.green = color.green;
+      xft_color.color.blue = color.blue;
+      xft_color.color.alpha = 0xffff;
+      
+      pango_xft_render (gc_x11->xft_draw, &xft_color,
+                       font, glyphs, x, y);
+    }
+  else
+#endif  /* !HAVE_XFT */
+    pango_x_render (impl->xdisplay,
+                   impl->xid,
+                   GDK_GC_GET_XGC (gc),
+                   font, glyphs, x, y);
 }
 
 static void
index ad3dc65caac084fa3280325c72b3433a954000c8..8d3dcdae492a025ec9deac99dac6b10da05c3f7b 100644 (file)
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#include <config.h>
+
+#if HAVE_XFT
+#include <pango/pangoxft.h>
+#endif
+
 #include "gdkgc.h"
-#include "gdkx.h"
+#include "gdkprivate-x11.h"
 #include "gdkregion-generic.h"
 
 #include <string.h>
@@ -107,6 +113,11 @@ gdk_gc_x11_finalize (GObject *object)
     gdk_region_destroy (x11_gc->clip_region);
   
   XFreeGC (GDK_GC_XDISPLAY (x11_gc), GDK_GC_XGC (x11_gc));
+
+#if HAVE_XFT
+  if (x11_gc->xft_draw)
+    XftDrawDestroy (x11_gc->xft_draw);
+#endif  
   
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
@@ -148,6 +159,9 @@ _gdk_x11_gc_new (GdkDrawable      *drawable,
       private->dirty_mask |= GDK_GC_DIRTY_TS;
     }
 
+  if (values_mask & GDK_GC_FOREGROUND)
+    private->fg_pixel = values->foreground.pixel;
+  
   xvalues.function = GXcopy;
   xvalues.fill_style = FillSolid;
   xvalues.arc_mode = ArcPieSlice;
@@ -386,6 +400,9 @@ gdk_x11_gc_set_values (GdkGC           *gc,
        }
     }
 
+  if (values_mask & GDK_GC_FOREGROUND)
+    x11_gc->fg_pixel = values->foreground.pixel;
+  
   gdk_x11_gc_values_to_xvalues (values, values_mask, &xvalues, &xvalues_mask);
 
   XChangeGC (GDK_GC_XDISPLAY (gc),
@@ -717,4 +734,5 @@ gdk_gc_copy (GdkGC *dst_gc, GdkGC *src_gc)
     x11_dst_gc->clip_region = NULL;
 
   x11_dst_gc->dirty_mask = x11_src_gc->dirty_mask;
+  x11_dst_gc->fg_pixel = x11_src_gc->fg_pixel;
 }
index 5fc19a2d0b9e1af5408aeb8e47fafc71fcca8bff..e657170845c7f4657912e974cc9e8291b5e26242 100644 (file)
@@ -382,7 +382,7 @@ _gdk_window_move_resize_child (GdkWindow *window,
 }
 
 static void
-gdk_window_compute_position (GdkWindowImplX11      *window,
+gdk_window_compute_position (GdkWindowImplX11   *window,
                             GdkWindowParentPos *parent_pos,
                             GdkXPositionInfo   *info)
 {
index 3c347905337ef7fef0c38e05795b2ca08498148a..b189cd6a5f62e1e749e65d96b2777b20588247b1 100644 (file)
@@ -257,6 +257,8 @@ gdk_x11_convert_grab_status (gint status)
     }
 
   g_assert_not_reached();
+
+  return 0;
 }
 
 /*
index a432921e0d3c3a08c89460e2310652c062ad2945..09e44f4450c28e2bc443305305c5f61ae6fdb1c8 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
+#include <stdlib.h>
+
 #include "gdkprivate-x11.h"
 #include "gdkpango.h"
 #include <pango/pangox.h>
+#ifdef HAVE_XFT
+#include <pango/pangoxft.h>
+#endif
 
 PangoContext *
 gdk_pango_context_get (void)
 {
-  return pango_x_get_context (GDK_DISPLAY ());
+#ifdef HAVE_XFT
+  static gint use_xft = -1;
+  if (use_xft == -1)
+    {
+      char *val = g_getenv ("GDK_USE_XFT");
+
+      use_xft = val && (atoi (val) != 0);
+    }
+  
+  if (use_xft)
+    return pango_xft_get_context (GDK_DISPLAY (), DefaultScreen (GDK_DISPLAY ()));
+  else
+#endif /* HAVE_XFT */
+    return pango_x_get_context (GDK_DISPLAY ());
 }
index 2a53104be1b24cfe59fba0cdc221c98f68e2ccc8..70aa809b66482453ad0d69a4fd7a89885a7865be 100644 (file)
@@ -43,9 +43,11 @@ gint          gdk_send_xevent          (Window           window,
                                        gboolean         propagate,
                                        glong            event_mask,
                                        XEvent          *event_send);
-GdkGC *       _gdk_x11_gc_new          (GdkDrawable     *drawable,
-                                       GdkGCValues     *values,
-                                       GdkGCValuesMask  values_mask);
+
+GdkGC *_gdk_x11_gc_new                  (GdkDrawable     *drawable,
+                                        GdkGCValues     *values,
+                                        GdkGCValuesMask  values_mask);
+
 GdkColormap * gdk_colormap_lookup      (Colormap         xcolormap);
 GdkVisual *   gdk_visual_lookup        (Visual          *xvisual);
 
index 3aee23b0331f0c0f775511a2076db5bf69861294..f5e511bceaa784c9988e1e95aa493bbdb8795ec0 100644 (file)
@@ -83,10 +83,11 @@ static gboolean gdk_window_icon_name_set          (GdkWindow *window);
 
 static GdkColormap* gdk_window_impl_x11_get_colormap (GdkDrawable *drawable);
 static void         gdk_window_impl_x11_set_colormap (GdkDrawable *drawable,
-                                                  GdkColormap *cmap);
-static void         gdk_window_impl_x11_get_size     (GdkDrawable *drawable,
-                                                  gint *width,
-                                                  gint *height);
+                                                     GdkColormap *cmap);
+static void         gdk_window_impl_x11_get_size    (GdkDrawable *drawable,
+                                                    gint *width,
+                                                    gint *height);
+static GdkRegion*  gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable);
 static void gdk_window_impl_x11_init       (GdkWindowImplX11      *window);
 static void gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass);
 static void gdk_window_impl_x11_finalize   (GObject            *object);
@@ -147,6 +148,10 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
   drawable_class->set_colormap = gdk_window_impl_x11_set_colormap;
   drawable_class->get_colormap = gdk_window_impl_x11_get_colormap;
   drawable_class->get_size = gdk_window_impl_x11_get_size;
+
+  /* Visible and clip regions are the same */
+  drawable_class->get_clip_region = gdk_window_impl_x11_get_visible_region;
+  drawable_class->get_visible_region = gdk_window_impl_x11_get_visible_region;
 }
 
 static void
@@ -235,6 +240,22 @@ gdk_window_impl_x11_get_size (GdkDrawable *drawable,
     *height = GDK_WINDOW_IMPL_X11 (drawable)->height;
 }
 
+static GdkRegion*
+gdk_window_impl_x11_get_visible_region (GdkDrawable *drawable)
+{
+  GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (drawable);
+  GdkRectangle result_rect;
+
+  result_rect.x = 0;
+  result_rect.y = 0;
+  result_rect.width = impl->width;
+  result_rect.height = impl->height;
+
+  gdk_rectangle_intersect (&result_rect, &impl->position_info.clip_rect, &result_rect);
+
+  return gdk_region_rectangle (&result_rect);
+}
+
 void
 _gdk_windowing_window_init (void)
 {
index 697afea9adbbe45f6274ba989944d02d1b02aa3d..336bd35f31ed035e7d8de0d28931f2b07a2f0e1c 100644 (file)
@@ -36,7 +36,6 @@
 #include <gdk/x11/gdkwindow-x11.h>
 #include <gdk/x11/gdkpixmap-x11.h>
 
-typedef struct _GdkGCXData             GdkGCXData;
 typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11;
 typedef struct _GdkCursorPrivate       GdkCursorPrivate;
 typedef struct _GdkFontPrivateX        GdkFontPrivateX;
@@ -120,6 +119,12 @@ struct _GdkGCX11
   Display *xdisplay;
   GdkRegion *clip_region;
   guint dirty_mask;
+
+  /* We can't conditionalize on HAVE_XFT here, so we simply always
+   * have this here as a gpointer.
+   */
+  gpointer xft_draw;
+  gulong fg_pixel;
 };
 
 struct _GdkGCX11Class
index fa50c68a6c633d1a4efe254a8e66802e39adf6ca..06f8367b9d480439d9c9b46fe90be23117f4dd43 100644 (file)
@@ -559,7 +559,7 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
 {
   PangoFontDescription **descs;
   int n_descs, i;
-  gint match_row = 0;
+  gint match_row = -1;
   gchar *str;
   
   pango_context_list_fonts (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
@@ -590,8 +590,11 @@ gtk_font_selection_show_available_styles (GtkFontSelection *fontsel)
     }
 
   gtk_clist_select_row (GTK_CLIST (fontsel->font_style_clist), match_row, 0);
-  gtk_clist_get_text (GTK_CLIST (fontsel->font_style_clist), match_row, 0, &str);
-  gtk_entry_set_text (GTK_ENTRY (fontsel->font_style_entry), str);
+  if (match_row >= 0)
+    {
+      gtk_clist_get_text (GTK_CLIST (fontsel->font_style_clist), match_row, 0, &str);
+      gtk_entry_set_text (GTK_ENTRY (fontsel->font_style_entry), str);
+    }
   
   gtk_clist_thaw (GTK_CLIST(fontsel->font_style_clist));
 
index 636e98c5d9d3cd7fc73a8f1f93739201e60e4d15..5a12f67e1ad609f024a5507bd84b673e4992d1b9 100644 (file)
@@ -2057,8 +2057,8 @@ void create_labels (void)
       gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
       frame = gtk_frame_new ("Bidirection Label");
-      label = gtk_label_new ("Arabic  السلام عليكم\n"
-                            "Hebrew   שלום");
+      label = gtk_label_new ("Arabic   السلام عليكم\n"
+                            "Hebrew    שלום");
       gtk_widget_set_direction (label, GTK_TEXT_DIR_RTL);
       gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
       gtk_container_add (GTK_CONTAINER (frame), label);
index 636e98c5d9d3cd7fc73a8f1f93739201e60e4d15..5a12f67e1ad609f024a5507bd84b673e4992d1b9 100644 (file)
@@ -2057,8 +2057,8 @@ void create_labels (void)
       gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
       frame = gtk_frame_new ("Bidirection Label");
-      label = gtk_label_new ("Arabic  السلام عليكم\n"
-                            "Hebrew   שלום");
+      label = gtk_label_new ("Arabic   السلام عليكم\n"
+                            "Hebrew    שלום");
       gtk_widget_set_direction (label, GTK_TEXT_DIR_RTL);
       gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
       gtk_container_add (GTK_CONTAINER (frame), label);